package com.ruoyi.demo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.demo.domain.BFlowerSceneCategory;
import com.ruoyi.demo.service.IBFlowerSceneCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 鲜花场景分类Controller
 * 
 * @author YY
 * @date 2025-11-09
 */
@RestController
@RequestMapping("/demo/category")
public class BFlowerSceneCategoryController extends BaseController
{
    @Autowired
    private IBFlowerSceneCategoryService bFlowerSceneCategoryService;

    /**
     * 查询鲜花场景分类列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(BFlowerSceneCategory bFlowerSceneCategory)
    {
        startPage();
        List<BFlowerSceneCategory> list = bFlowerSceneCategoryService.selectBFlowerSceneCategoryList(bFlowerSceneCategory);
        return getDataTable(list);
    }

    /**
     * 导出鲜花场景分类列表
     */
    @Anonymous
    @Log(title = "鲜花场景分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BFlowerSceneCategory bFlowerSceneCategory)
    {
        //测试后端代码推送
        List<BFlowerSceneCategory> list = bFlowerSceneCategoryService.selectBFlowerSceneCategoryList(bFlowerSceneCategory);
        ExcelUtil<BFlowerSceneCategory> util = new ExcelUtil<BFlowerSceneCategory>(BFlowerSceneCategory.class);
        util.exportExcel(response, list, "鲜花场景分类数据");
    }

    /**
     * 获取鲜花场景分类详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bFlowerSceneCategoryService.selectBFlowerSceneCategoryById(id));
    }

    /**
     * 新增鲜花场景分类
     */
    @Anonymous
    @Log(title = "鲜花场景分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BFlowerSceneCategory bFlowerSceneCategory)
    {
        return toAjax(bFlowerSceneCategoryService.insertBFlowerSceneCategory(bFlowerSceneCategory));
    }

    /**
     * 修改鲜花场景分类
     */
    @Anonymous
    @Log(title = "鲜花场景分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BFlowerSceneCategory bFlowerSceneCategory)
    {
        return toAjax(bFlowerSceneCategoryService.updateBFlowerSceneCategory(bFlowerSceneCategory));
    }

    /**
     * 删除鲜花场景分类
     */
    @Anonymous
    @Log(title = "鲜花场景分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bFlowerSceneCategoryService.deleteBFlowerSceneCategoryByIds(ids));
    }
}
